<%@ page language="java" import="java.util.*"  pageEncoding="utf-8"%>
<%@include file="common/tag.jsp"%>
<c:set var="CTX" value="${pageContext.request.contextPath}" />
<%@include file="common/indexhead.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <base href="<%=basePath%>">
    
    <title>工艺加工单（${processprocess.processProcessType}）详情页</title>
    </head>
  <style>
  .panel .panel-heading button {
  	padding: ;
	margin-left: ;
	background-color: ;
	border: ;
	outline: ;
  }
  </style>
 <body>
<div class="panel panel-primary">
	<div class="panel-heading">
		<div>
			<h3 class="panel-title">工艺加工单（${processprocess.processProcessType}）详情页</h3>
		</div>
		<div class="button"
			style="float: right;margin-top: -27px;margin-right: 5px;">
			<a class="btn btn-info" href="#" onclick="javascript:window.close();"><i class="fa fa-sign-out"></i>退出</a>
		</div>
		<div id="isbc" class="button"
			style="float: right;margin-top: -27px;margin-right: 5px;">
			<div class="btn btn-info"   onclick="tijiao('')" href=""><i class="fa fa-check"></i>保存</div>
		</div>
		<div id="isrk" class="button"
			style="float: right;margin-top: -27px;margin-right: 5px;">
			<div class="btn btn-info"   onclick="tijiao('rk')" href=""><i class="fa fa-check"></i>入库</div>
		</div>
		<div id="isll" class="button"
			style="float: right;margin-top: -27px;margin-right: 5px;">
			<div class="btn btn-info"   onclick="tijiao('ll')" href=""><i class="fa fa-check"></i>领料</div>
		</div>
		<div id="istj" class="button"
			style="float: right;margin-top: -27px;margin-right: 5px;">
			<div class="btn btn-info"   onclick="tijiao('tj')" href=""><i class="fa fa-check"></i>提交</div>
		</div>
		<div id="isck" class="button"
			style="float: right;margin-top: -27px;margin-right: 5px;">
			<div class="btn btn-info"   onclick="tijiao('ck')" href=""><i class="fa fa-check"></i>出库</div>
		</div>
		<div id="isth" class="button"
			style="float: right;margin-top: -27px;margin-right: 5px;">
			<div class="btn btn-info"   onclick="tijiao('th')" href=""><i class="fa fa-check"></i>退回</div>
		</div>
	</div>
	<div class="panel-body">

		<!-- <form modelAttribute="User"    id="userdetail" action="/user/update" method="POST" class="form-horizontal" -->
			<form    action="/processprocess/update" method="post"  id="processprocessupdate"  class="form-horizontal"
			style="width:95%;margin-top: 50px;">
			<fieldset>
			<table class="table table-bordered">
				<div class="form-group">
					<label class="col-sm-1 control-label">加工单号</label>
					<div class="col-sm-3">
						<input readOnly=true class="form-control" id="processProcessJgdh" name="processProcessJgdh" type="text"
						placeholder = "${processprocess.processProcessJgdh}" value = "${processprocess.processProcessJgdh}"/>
					</div>
					<label class="col-sm-1 control-label">生产计划</label>
					<div class="col-sm-3">
						<input readOnly=true style="width:55%;display: inline-block;" class="form-control" id="processProcessScjh" name="processProcessScjh" type="text"
						placeholder = "${processprocess.processProcessScjh}" value = "${processprocess.processProcessScjh}"/>
						<input style="display:none" class="form-control" id="processProcessScjhId" name="processProcessScjhId" type="text"
						placeholder = "${processprocess.processProcessScjhId}" value = "${processprocess.processProcessScjhId}"/>
						<a class="btn btn-info"  onclick="showdialog_dhd();"><i class="fa fa-sign-out"></i>计划单</a>
					</div>
					<label class="col-sm-1 control-label">单据日期</label>
					<div class="col-sm-3">
						<input readOnly=true class="form-control mydate" id="processProcessDjrq" name="processProcessDjrq" type="text"
						placeholder = "<fmt:formatDate value="${processprocess.processProcessDjrq}" pattern="MM/dd/yyyy"/>" value = "<fmt:formatDate value="${processprocess.processProcessDjrq}" pattern="MM/dd/yyyy"/>"/>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-1 control-label">备注</label>
					<div class="col-sm-11">
						<input class="form-control" id="processProcessBz" name="processProcessBz" type="text"
						placeholder = "${processprocess.processProcessBz}" value = "${processprocess.processProcessBz}"/>
					</div>
				</div>
				</table>
			</fieldset>
			<hr></hr>
<style>
.table >thead> tr> th{
	text-align:center;
	vertical-align: middle;
	background-color: #DDD9D4;
	border-color:#BEC2C1;
	padding-left: 0px;
}
.table >tbody> tr> td>input{
	width:100%;
}
.table >tbody> tr> td {
	text-align:center;
	width:8%
}
</style>
<table class="table table-bordered">
  <caption style="width:90%">工艺流程
  <p style="float:right;width:50%;text-align:right">
  <a style="display:none"   onclick="addTable();" class="btn btn-info">增加商品</a>
  <a  style="display:none"  onclick="del();" class="btn btn-danger">批量删除</a>
  </p></caption>
  <thead>
    <tr>
	 <th>工序名称</th>
      <th>零件名称</th>
      <th>任务数量</th>
      <th>操作人</th>
      <th>工序内容</th>
      <th>工序时长</th>
      <th>完成数量</th>
      <th>未完数量</th>
      <th>检验员</th>
    </tr>
  </thead>
  <tbody id="addTable">
	    <c:forEach var="details" items="${processprocess.details}"  varStatus="status">
			<tr>
				<td>${details.processDetailsName}</td>
				<td style='display:none'><input class='form-control' value='${details.processDetailsLjmcId}' type='text' name='datarwsl' ></td>
				<td><input onclick='checkhpxx(this);' class='form-control' value='${details.processDetailsLjmc}' type='text' name='datarwsl' ></td>
				<td><input class='form-control' value='${details.processDetailsRwsl}' type='text' name='datarwsl' ></td>
				<td style='display:none'><input class='form-control' value='${details.processDetailsCzrId}' type='text' name='datarwsl' ></td>
				<td><input onclick='user(this)' class='form-control' value='${details.processDetailsCzr}' type='text' name='datarwsl' ></td>
				<td><input class='form-control' value='${details.processDetailsGxnr}' type='text' name='datarwsl' ></td>
				<td><input class='form-control' value='${details.processDetailsGxsc}' type='text' name='datarwsl' ></td>
				<td><input class='form-control' value='${details.processDetailsWcsl}' type='text' name='datarwsl' ></td>
				<td><input class='form-control' value='${details.processDetailsWwcsl}' type='text' name='datarwsl' ></td>
				<td style='display:none'><input class='form-control' value='${details.processDetailsJyyId}' type='text' name='datarwsl' ></td>
				<td><input onclick='user(this)' class='form-control' value='${details.processDetailsJyy}' type='text' name='datarwsl' ></td>
				<td style='display:none'><input class='form-control' value='${details.processDetailsId}' type='text' name='datarwsl' ></td>
			</tr>
		</c:forEach> 
  </tbody>
</table>
		</form>
		<hr></hr>
		

	</div>
</div>
<%@include file="common/indexbottom.jsp"%>
<div id="deptdialoggoods">
	<%@include file="checkgoodsforscjhd.jsp" %>
</div>
<div id="deptdialogforthis">
	<%@include file="checkProductionPlan.jsp" %>
</div>
<div id="dialogfordept">
	<%-- <%@include file="checkzTreeNew.jsp"%> --%>
	<div class="zTreeDemoBackground" style="float:left">
		<ul id="treeDemo1" class="ztree"></ul>
	</div>
</div>
<!-- 弹出框重写 -->
<div id="ycf-alert" class="modal">
      <div class="modal-dialog modal-sm">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
            <h5 class="modal-title"><i class="fa fa-exclamation-circle"></i> [Title]</h5>
          </div>
          <div class="modal-body small">
            <p>[Message]</p>
          </div>
          <div class="modal-footer" >
            <button type="button" class="btn btn-primary ok" data-dismiss="modal">[BtnOk]</button>
            <button type="button" class="btn btn-default cancel" data-dismiss="modal">[BtnCancel]</button>
          </div>
        </div>
      </div>
    </div>
<!-- 弹出框重写end -->
<script type="text/javascript">
function buttons(){
	$("#isrk").hide();
	$("#istj").hide();
	$("#isck").hide();
	$("#isbc").hide();
	$("#isll").hide();
	$("#isth").hide();
	if("${fd.ruKu}"!=""){
		if("${fd.ruKu}"=="是"){
			$("#isrk").show();
		}
	}
	if("${fd.tiJiao}"!=""){
		if("${fd.tiJiao}"=="是"){
			$("#istj").show();
		}
	}
	if("${fd.chuKu}"!=""){
		if("${fd.chuKu}"=="是"){
			$("#isck").show();
		}
	}
	if("${fd.baoCun}"!=""){
		if("${fd.baoCun}"=="是"){
			$("#isbc").show();
		}
	}
	if("${fd.lingLiao}"!=""){
		if("${fd.lingLiao}"=="是"){
			$("#isll").show();
		}
	}
	if("${fd.tuiHui}"!=""){
		if("${fd.tuiHui}"=="是"){
			$("#isth").show();
		}
	}
}
function showdialog_dhd(url){
	//$("#deptdialog").html('<iframe src="' + url + '" frameborder="0" height="100%" width="100%" id="dialogFrame" scrolling="auto"></iframe>');
	$("#deptdialogforthis").dialog("open");
}

//fenye(${pb.currentPage},${pb.totalPages},${pb.totalRecords},${pb.pagesize},yongan.URL.salesOrderList());
var a;
var b;
function checkhpxx(obj){
	//console.log(obj.parentNode.previousSibling.previousSibling);
	a = obj.parentNode.previousSibling.previousSibling.childNodes[0];//ID
	b = obj;
	$("#deptdialoggoods").dialog("open");
}
var json1 = ${allusers};
var userv;
var userid;
function user(obj){
	//console.log(obj);
	$("#dialogfordept").dialog("open");
	userid = obj.parentNode.previousSibling.previousSibling.childNodes[0];//ID
	userv = obj;
	//yongan.dialog.showdialog('/util/usertree','deptdialog','outsourcinginShr','outsourcinginShrId');
}

function isll(){
var isll = ${processprocess.processProcessIsll};
$("#isll").css("display","none");
	if(isll){
		$("#isll").css("display","none");
	}else{
		$("#isll").css("display","");
	}
}
$(function() {
buttons();
isll();
var setting1 = {
			data: {
				simpleData: {
					enable: true
				}
			},
			check :{
				radioType : "all",
				enable: true,
				chkStyle: "radio"
			}
		};

		var json1 = ${allusers};
        var zNodes1 = eval(json1);

		$(document).ready(function(){
			$.fn.zTree.init($("#treeDemo1"), setting1, zNodes1);
			
		});
$("#deptdialogforthis").dialog({
		autoOpen : false,   // 是否自动弹出窗口
		modal : true,    // 设置为模态对话框
		resizable : true,
		width : 810,   //弹出框宽度
		height : 440,   //弹出框高度
		title : "选择生产计划",  //弹出框标题
		position : "center",  //窗口显示的位置
		buttons:{
			'确定':function(){
				var checked = $("input[type='radio'][name='rd']"); 
				$(checked).each(function(){ 
					if($(this).prop('checked')){ //注意：此处判断不能用$(this).attr("checked")==‘true'来判断。 
						//alert($(this).parent().next().next().html()); 
						$("#processProcessScjhId").val($(this).parent().next().html());
						$("#processProcessScjh").val($(this).parent().next().next().html());
						//getValue($(this).parent().next().html());
					} 
				});
				$(this).dialog("close");
			},
			'取消':function(){
			$(this).dialog("close");
			}
		}
	});
$("#deptdialoggoods").dialog({
		autoOpen : false,   // 是否自动弹出窗口
		modal : true,    // 设置为模态对话框
		resizable : true,
		width : 810,   //弹出框宽度
		height : 440,   //弹出框高度
		title : "选择货品",  //弹出框标题
		position : "center",  //窗口显示的位置
		buttons:{
			'确定':function(){
				var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
				if(treeObj.getCheckedNodes().length!=0){
					var checkId = treeObj.getCheckedNodes()[0];
					a.value = checkId.rid;
					b.value = checkId.name;
					//yongan.dialog.addhpxx(checkId);
					//$("#goodsinformationNumber").val(checkId.id);
					//$("#productionPlangoodsId").val(checkId.rid);
					//getValue(checkId.rid);
				}else{
					alert("请选择货品信息！");
					return false;
				}
				$(this).dialog("close");
			},
			'取消':function(){
			$(this).dialog("close");
			}
		}
	});
$("#dialogfordept").dialog({
		autoOpen : false,   // 是否自动弹出窗口
		modal : true,    // 设置为模态对话框
		resizable : true,
		width : 810,   //弹出框宽度
		height : 440,   //弹出框高度
		title : "选择用户",  //弹出框标题
		position : "center",  //窗口显示的位置
		buttons:{
			'确定':function(){
				var treeObj1 = $.fn.zTree.getZTreeObj("treeDemo1");
				if(treeObj1.getCheckedNodes().length!=0){
					var checkId = treeObj1.getCheckedNodes()[0];
					userv.value = checkId.name;
					userid.value = checkId.id;
				}else{
					alert("请选择用户信息！");
					return false;
				}
				$(this).dialog("close");
			},
			'取消':function(){
			$(this).dialog("close");
			}
		}
	});
$(".mydate").datepicker();
window.Modal = function() {
    var reg = new RegExp("\\[([^\\[\\]]*?)\\]", 'igm');
    var alr = $("#ycf-alert");
    var ahtml = alr.html();
    
    var _alert = function(options) {
        alr.html(ahtml); // 复原
        alr.find('.ok').removeClass('btn-success').addClass('btn-primary');
        alr.find('.cancel').hide();
        _dialog(options);

        return {
            on: function(callback) {
                if (callback && callback instanceof Function) {
                    alr.find('.ok').click(function() {
                        callback(true)
                    });
                }
            }
        };
    };

    var _confirm = function(options) {
        alr.html(ahtml); // 复原
        alr.find('.ok').removeClass('btn-primary').addClass('btn-success');
        alr.find('.cancel').show();
        _dialog(options);

        return {
            on: function(callback) {
                if (callback && callback instanceof Function) {
                    alr.find('.ok').click(function() {
                        callback(true)
                    });

                }
            }
        };
    };

    var _dialog = function(options) {
        var ops = {
            msg: "提示内容",
            title: "操作提示",
            btnok: "确定",
            btncl: "取消"
        };

        $.extend(ops, options);

        console.log(alr);

        var html = alr.html().replace(reg,
        function(node, key) {
            return {
                Title: ops.title,
                Message: ops.msg,
                BtnOk: ops.btnok,
                BtnCancel: ops.btncl
            } [key];
        });

        alr.html(html);
        alr.modal({
            width: 500,
            backdrop: 'static'
        });
    }

    return {
        alert: _alert,
        confirm: _confirm
    }

} ();
});
function lingliao() {
var productionPlanId = "${productionplan.productionPlanId}";
var productstructurelistId = $("#productstructurelistId").val();
if(productionPlanId.length>3 && productstructurelistId.length>3){
	var url = "/productionplan/"+productionPlanId+"/"+productstructurelistId+"/lingliao";
}else{
	alert("领料有误！请联系管理员");
}
Modal.confirm({
    msg: "是否确定领料？"
}).on(function(e) {
    $.ajax({
        type: "get",
        url: url,
        dataType: "json",
        data: "",
        success: function(data) {

            if (data['success']) {
                Modal.alert({
                    msg: data['data']['stateinfo'],
                    title: '执行结果',
                    btnok: '确定',
                    btncl: '取消'
                }).on(function(e) {
                    window.location.reload();
                });
            }
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert(XMLHttpRequest);
            alert(textStatus);
            alert(errorThrown);
        }
    });
});
}
function tijiao(isflowwork) {
if("${performer}"!="<%=request.getSession().getAttribute("userid")%>"){
	alert("您不是当前处理人！");
	//return false;
}
Modal.confirm({
    msg: "是否保存该条数据？"
}).on(function(e) {
    var jsondata = "{";
	var alltable = $("#addTable").children();
	for(var i=0;i<alltable.length;i++){
		jsondata=jsondata+"'details["+i+"].processDetailsName':'"+alltable[i].children[0].innerHTML+"',";
		jsondata=jsondata+"'details["+i+"].processDetailsLjmcId':'"+alltable[i].children[1].childNodes[0].value+"',";
		jsondata=jsondata+"'details["+i+"].processDetailsLjmc':'"+alltable[i].children[2].childNodes[0].value+"',";
		jsondata=jsondata+"'details["+i+"].processDetailsRwsl':'"+alltable[i].children[3].childNodes[0].value+"',";
		jsondata=jsondata+"'details["+i+"].processDetailsCzrId':'"+alltable[i].children[4].childNodes[0].value+"',";
		jsondata=jsondata+"'details["+i+"].processDetailsCzr':'"+alltable[i].children[5].childNodes[0].value+"',";
		jsondata=jsondata+"'details["+i+"].processDetailsGxnr':'"+alltable[i].children[6].childNodes[0].value+"',";
		jsondata=jsondata+"'details["+i+"].processDetailsGxsc':'"+alltable[i].children[7].childNodes[0].value+"',";
		jsondata=jsondata+"'details["+i+"].processDetailsWcsl':'"+alltable[i].children[8].childNodes[0].value+"',";
		jsondata=jsondata+"'details["+i+"].processDetailsWwcsl':'"+alltable[i].children[9].childNodes[0].value+"',";
		jsondata=jsondata+"'details["+i+"].processDetailsJyyId':'"+alltable[i].children[10].childNodes[0].value+"',";
		jsondata=jsondata+"'details["+i+"].processDetailsJyy':'"+alltable[i].children[11].childNodes[0].value+"',";
		jsondata=jsondata+"'details["+i+"].processDetailsId':'"+alltable[i].children[12].childNodes[0].value+"',";
		jsondata=jsondata+"'details["+i+"].processDetailsOrder':'"+i+"',";
	}
	jsondata=jsondata+"'processProcessId':'${processprocess.processProcessId}',";
	jsondata=jsondata+"'processProcessType':'${type}',";
	jsondata=jsondata+"'processProcessJgdh':'"+$("#processProcessJgdh").val()+"',";
	jsondata=jsondata+"'processProcessScjh':'"+$("#processProcessScjh").val()+"',";
	jsondata=jsondata+"'processProcessScjhId':'"+$("#processProcessScjhId").val()+"',";
	jsondata=jsondata+"'processProcessDjrq':'"+$("#processProcessDjrq").val()+"',";
	jsondata=jsondata+"'processProcessBz':'"+$("#processProcessBz").val()+"'";
	jsondata=jsondata+"}";
	console.log(jsondata);
	var b=eval('(' + jsondata+ ')');
    $.ajax({
        type: "post",
        url: yongan.URL.processprocessUpdate()+"?isflowwork="+isflowwork+"&flowtype=${processprocess.processProcessType}",
        dataType: "json",
        data: b,
        success: function(data) {

            if (data['success']) {
                Modal.alert({
                    msg: data['data']['stateinfo'],
                    title: '执行结果',
                    btnok: '确定',
                    btncl: '取消'
                }).on(function(e) {
                    window.close();
                });
            }
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert(XMLHttpRequest);
            alert(textStatus);
            alert(errorThrown);
        }
    });
});
}
</script>
  </body>
</html>